<template>
	<div>
		<el-form :inline="true" :model="formInline" class="demo-form-inline">
		<el-form-item label="员工姓名">
		<el-input v-model="formInline.name" placeholder="员工姓名"></el-input>
		</el-form-item>
		<el-form-item>
		<el-button type="primary" @click="onSubmit">查询</el-button>
		<el-button type="danger" @click="del">清空</el-button>
		</el-form-item>
		</el-form>
		<el-table
		:data="tableData"
		height="400"
		border
		style="width: 100%">
		<el-table-column
		prop="log"
		label="日志"
		>
		</el-table-column>
		</el-table>
	</div>
</template>
<script>
	import {mapActions,mapState} from 'vuex'
	export default{
		name:'caozuorzhi',
		data(){
			return{
				formInline:{},
				// tableData:[]
			}
		},
		methods:{
			...mapActions(['getlog','dellog']),
			onSubmit(){
				if(this.formInline.name){
					this.getlog(this.formInline.name).then(res=>{
						if(res==='400'){
							this.$notify({
								showClose: true,
								message: '无操作日志数据!',
								type: 'info'
							});
						}
					})
				}
			},
			del(){
				if(this.logs.length>1){
					// console.log(this.formInline.name)
					this.dellog(this.formInline.name).then(res=>{
						if(res==='200'){
							// this.log('清空了'+this.name+'的操作日志记录')
						}
					})
				}
			}
		},
		computed:{
			...mapState({
				logs:state=>state.xtsz.logData,
				name:state=>state.xtsz.name
			}),
			tableData(){
				console.log(this.logs)
				return this.logs
			}
		}
	}
</script>